package com.cqw.commontest.designmode.strategy;

import java.util.Arrays;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-09-23 18:28
 * @Description: 策略模式
 */
public class StrategyTest {

    public static void main(String[] args) {
        Sorter sorter = new Sorter();
        //System.out.println(Arrays.toString(arr));

        Cat[] cats = {new Cat(3, 3), new Cat(5, 5), new Cat(1, 1)};
        sorter.sort(cats);
        //System.out.println(Arrays.toString(cats));

        Dog[] dogs = {new Dog(2), new Dog(1), new Dog(5)};
        sorter.sort(dogs);
        //System.out.println(Arrays.toString(dogs));

        //========================================================

        Cat[] cats1 = {new Cat(3, 3), new Cat(5, 5), new Cat(1, 1)};
        Sorter<Cat> catSorter = new Sorter<>();
//        catSorter.sort(cats1, new Comparator<Cat>() {
//            @Override
//            public int compare(Cat o1, Cat o2) {
//                return 0;
//            }
//        });

        catSorter.sort(cats1, new CatWeightComparator());
        System.out.println(Arrays.toString(cats1));


    }


}
